{layout name="layout" /}

<div class="order-management">
    <h2>订单管理</h2>
    
    <form class="search-form" method="get" action="">
        <div class="form-group">
            <label for="keyword">查询关键字</label>
            <input type="text" id="keyword" name="keyword" value="{notempty name='keyword'}{$keyword}{/notempty}" placeholder="输入订单号或用户名">
            <input type="submit" value="查询">
        </div>
    </form>
    
    <div class="table-container">
        <table class="order-table">
            <thead>
                <tr>
                    <th>订单号</th>
                    <th>用户名</th>
                    <th>下单时间</th>
                    <th>总金额</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {foreach name="orders" item="order"}
                <tr>
                    <td>{$order.orderId}</td>
                    <td>{$order.uName}</td>
                    <td>{$order.orderDate}</td>
                    <td>¥{$order.totalPrice}</td>
                    <td class="status-{$order.status}">{$order.status}</td>
                    <td class="actions">
                        <a href="{:Url('admin/orders/detail', ['id' => $order.orderId])}" class="btn-detail">详情</a>
                        {if $order.status == '未付款'}
                        <a href="{:Url('admin/orders/updateStatus', ['id' => $order.orderId, 'status' => '已付款'])}" class="btn-update">标记为已付款</a>
                        {elseif $order.status == '已付款'}
                        <a href="{:Url('admin/orders/updateStatus', ['id' => $order.orderId, 'status' => '已发货'])}" class="btn-update">标记为已发货</a>
                        {elseif $order.status == '已发货'}
                        <a href="{:Url('admin/orders/updateStatus', ['id' => $order.orderId, 'status' => '已完成'])}" class="btn-update">标记为已完成</a>
                        {/if}
                        <a href="{:Url('admin/orders/delete', ['id' => $order.orderId])}" class="btn-delete" onclick="return confirm('确定删除此订单吗？')">删除</a>
                    </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>
    
    <div class="pagination">
        {$orders->render()}
    </div>
</div>